import request from '@/utils/request'
import axios from 'axios'

// 获取服务时长记录列表
export function getServiceHoursList(params) {
  return request({
    url: '/service-hours',
    method: 'get',
    params
  })
}

// 获取服务时长记录详情
export function getServiceHourDetail(id) {
  return request({
    url: `/service-hours/${id}`,
    method: 'get'
  })
}

// 审核通过时长记录
export function approveServiceHour(id) {
  return request({
    url: `/service-hours/${id}/approve`,
    method: 'post'
  })
}

// 拒绝时长记录
export function rejectServiceHour(id, reason) {
  return request({
    url: `/service-hours/${id}/reject`,
    method: 'post',
    data: { reason }
  })
}

// 导出服务时长记录 - 直接使用axios而不经过request拦截器
export function exportServiceHours(params) {
  const baseURL = 'http://localhost:8081/api'
  const token = localStorage.getItem('token')
  
  return axios({
    url: `${baseURL}/service-hours/export`,
    method: 'get',
    params,
    responseType: 'blob',
    headers: token ? { 'Authorization': `Bearer ${token}` } : {}
  })
}

// 获取项目列表(下拉选择用)
export function getProjectOptions() {
  return request({
    url: '/projects/options',
    method: 'get'
  })
} 